
package com.bdtop.dbl.server.request;

import com.bdtop.dbl.server.response.BaseResponse;
import com.bdtop.dbl.thirdparty.asynchttp.HttpPostRequest;
import com.bdtop.dbl.thirdparty.asynchttp.RequestCallback;
import com.bdtop.dbl.utils.Constants;
import com.bdtop.dbl.utils.DBLDebug;
import com.google.gson.Gson;

/**
 * @ClassName: FenceSetRequest
 * @Description: TODO
 * @author: liyongqiang
 * @date:2014-10-15
 */
public class FenceSetRequest extends HttpPostRequest {

    /**
     * @param callback
     */
    public FenceSetRequest(RequestCallback callback) {
        super(callback);
        getRequestParams().add(Constants.COMMAND, Constants.CMD_FENCE_SET);
    }

    public void setParams(String sign, String fence_id, String mdn, String open) {
        getRequestParams().add(Constants.PARAM_LOGIN_SIGN, sign);
        getRequestParams().add(Constants.PARAM_FENCE_ID, fence_id);
        getRequestParams().add(Constants.PARAM_MDN, mdn);
        getRequestParams().add(Constants.PARAM_OPEN, open);
    }

    @Override
    protected String getUrl() {
        return Constants.SERVER_ADDRESS;
    }

    @Override
    protected Object parse(String responseString) {
        DBLDebug.logd("FenceSetRequest, response = " + responseString);

        Gson gson = new Gson();
        BaseResponse response = gson.fromJson(responseString, BaseResponse.class);
        return response;
    }

}
